/**
 * S03
 * 类型守卫
 */

const str: any = 'sss'
str
if (typeof str === 'string') {
  str
}

// 自定义类型守卫
interface People {
  name: string
  type: 'man' | 'woman'
}

interface Man extends People {
  type: 'man'
  age: number
}

function isMan(people: any): people is Man {
  return people.type === 'man'
}

const people: any = {
  name: 'Join',
  type: 'man',
  age: 1,
}
people
if (isMan(people)) {
  people.age
}
